 <?php
    /**
     * This is a completely custom QControl and it is also a composite control,
     * meaning it utilizes several individual QControls (e.g. a QLabel and two
     * QButtons) to make one larger control.
     */
    class PanelTest extends QControl {
        // Our SubControls
        public $pnl;
        public $lst;
        public $txt;
        public $btn;

        protected $blnUseAjax = false;
        protected $strPadding = '10px';
        // Let's Override the Default Style Settings
        protected $strWidth = '200px';
        protected $strFontSize = '36px';
        protected $blnFontBold = true;
        protected $strBackColor = '';

        protected $blnIsBlockElement = true;

        protected $objParentObject;

        public    $bolDuplicate=true;
        public    $strCallList;
        public    $strReverseCall;
        public    $strGetId;

        // We want to override the constructor in order to setup the subcontrols
        public function __construct($objParentObject, $strControlId = null) {
            // First, call the parent to do most of the basic setup
            try {
                parent::__construct($objParentObject, $strControlId);
            } catch (QCallerException $objExc) {
                $objExc->IncrementOffset();
                throw $objExc;
            }

            $this->pnl = new QPanel($this);
            $this->pnl->Width= 210;
            $this->pnl->Height= 120;
            $this->Name="QPanel Name";
            $this->pnl->BackColor= "#F0F0F0";
           // $this->pnl->AutoRenderChildren = true;
            $this->pnl->Template = "qepanel.tpl.php";

            $this->pnl->Position =  QPosition::Absolute;
            // Define the Controls
            $this->objParentObject=$objParentObject;

            $this->lst = new QListBox($this);
            $this->lst->Name="lst";
            $this->lst->Rows = 6;
            $this->lst->Width = $this->strWidth;
            

            $this->txt = new QAjaxAutoCompleteTextBox($this, 'txt_Change');
            $this->txt->Name = "txt";

            $this->btn = new QButton($this->pnl);
            $this->btn->Name= "add";
            $this->btn->Text = 'Add';
            
           

        }

        public function ParsePostData() {}


        public function Validate() { return true;
        }

        // Now, for the fun part -- we get to define how our sample control gets rendered
        protected function GetControlHtml() {
            // Lets get Style attributes
            $strStyle = $this->GetStyleAttributes();
            if ($this->strPadding)
                $strStyle .= sprintf('padding:%s;', $this->strPadding);
            $strStyle = sprintf('style="%s;text-align:center;align=right;"', $strStyle);

            // Lets get all the other attributes -- because we have actions defined internally,
            // we specifically do not want to include externally defined actions.  Therefore,
            // we pass in "false" for the optional blnIncludeAction parameter
            $strAttributes = $this->GetAttributes(true, false);

            // Lets get the rendered subcontrols -- remember to use FALSE for "blnDisplayOutput"
            //$strItem = $this->txt->Render(false);
            //$strAdd =  $this->btn->Render(false);
            //$strListBox = $this->lst->Render(false);
            $strPnl  = $this->pnl->Render(false);
            // Let's render it out
            return sprintf('%s
                            ',

                $strPnl);
        }

        // And our public getter/setters
        public function __get($strName) {
            switch ($strName) {
                case 'Padding': return $this->strPadding;
                case 'UseAjax': return $this->blnUseAjax;
                default:
                    try {
                        return parent::__get($strName);
                    } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                    }
            }
        }

        public function __set($strName, $mixValue) {
            // Whenever we set a property, we must set the Modified flag to true
            $this->blnModified = true;

            try {
                switch ($strName) {
                    case 'Padding': return ($this->strPadding = QType::Cast($mixValue, QType::String));
                    case 'UseAjax':
                        $blnToReturn = ($this->blnUseAjax = QType::Cast($mixValue, QType::Boolean));

                        // Whenever we change UseAjax, we must be sure to update our two buttons
                        // and their defined actions.
                        $this->SetupButtonActions();

                        return $blnToReturn;

                    default:
                        return (parent::__set($strName, $mixValue));
                }
            } catch (QCallerException $objExc) {
                $objExc->IncrementOffset();
                throw $objExc;
            }
        }
    }
?>